	var map;
	var map_small;
	var geoXml;
	var geocoder = null;
	var markerArray=[];
	var lastWindow=null;
	var latlngbounds;
	function initialize_map() {
	  
	var mapOptions = {
	  center: new google.maps.LatLng(46, 25.5),
	  zoom: 7, 
	  disableDefaultUI: true,
	  mapTypeId: google.maps.MapTypeId.ROADMAP};
	  
	  
	map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
	MarkMap();
	}
	
	function initialize_map_small() {
		  
	var mapOptions_small = {
	  center: new google.maps.LatLng(46, 25.5),
	  zoom: 6, 
	  disableDefaultUI: true,
	  mapTypeId: google.maps.MapTypeId.ROADMAP};	  
	
	map_small = new google.maps.Map(document.getElementById("map_canvas_small"),mapOptions_small);
	
	}
	
	function LoadData(){
		  var query = "localhost/angajatori.php";
		  var filter = "";
		  var queryUrl = query + filter;
		  $.getJSON(queryUrl, null, AdditionalData_Loaded);
	}
	
	function addMarker(filter) {
	
	var locatii=LoadData(filter);
	

	
	var location= new google.maps.LatLng(45.74738913515841, 25.55419921875);
	  marker = new google.maps.Marker({
	  position:location,
		map: map
	});
	}
	
	function resetMap(){
		try{
			map.setZoom(7);
			map.panTo(new google.maps.LatLng(46, 25.5));	
		} catch (err){}
		try{
			map_small.setZoom(6);
			map_small.panTo(new google.maps.LatLng(45.74738913515841, 25.55419921875));	
			map_small.setCenter(latlngbounds.getCenter());
		} catch (err){}
	}
	
	function populate_small_map(){
		latlngbounds = new google.maps.LatLngBounds();
			     var d=JSON.parse($("#jsonData").html());
      for(i in d) {
        var titlu=d[i]['tip'];
        var location = new google.maps.LatLng(d[i]['latitudine'],d[i]['longitudine']);
        latlngbounds.extend(location);
        var marker= new google.maps.Marker({
          position:location,
          map: map_small});
        markerArray.push(marker);
        var contentString = '<a href="post.php?entityid='+d[i]['entityid']+'">'+d[i]['angajator']+'</a>';  
       /* (function (marker, contentString) {
          google.maps.event.addListener(marker, 'click', function() {
          if (lastWindow!=null)
            lastWindow.close();
          var infowindow = new google.maps.InfoWindow({
            content: contentString
            });
          infowindow.open(map_small,marker);
          lastWindow=infowindow;
          (function(){infowindow.close()});
          });
        })(marker, contentString);*/
      }    
    map_small.setCenter(latlngbounds.getCenter());
	map_small.fitBounds(latlngbounds);
	setMaxZoom();

  }
  function setMaxZoom(){
  	var listener = google.maps.event.addListener(map_small, "idle", function() { 
		if (map_small.getZoom() > 14) map_small.setZoom(14); 
		google.maps.event.removeListener(listener); 
	});
  }
  function populate_small_map2(){
		latlngbounds = new google.maps.LatLngBounds();

			     var d=JSON.parse($("#jsonData").html());
      for(i in d) {
        var titlu=d[i]['tip'];
        var location = new google.maps.LatLng(d[i]['latitudine'],d[i]['longitudine']);
        latlngbounds.extend(location);
        var marker= new google.maps.Marker({
          position:location,
          map: map_small});
        markerArray.push(marker);
        var contentString = '<a href="'+d[i]['websiteangajator']+'">'+d[i]['angajator']+'</a>';  
        /*(function (marker, contentString) {
          google.maps.event.addListener(marker, 'click', function() {
          if (lastWindow!=null)
            lastWindow.close();
          var infowindow = new google.maps.InfoWindow({
            content: contentString
            });
          infowindow.open(map_small,marker);
          lastWindow=infowindow;
          (function(){infowindow.close()});
          });
        })(marker, contentString);*/
      }
    map_small.setCenter(latlngbounds.getCenter());
	map_small.fitBounds(latlngbounds);   
	setMaxZoom();  
  }
  function centerall(){
	    

	}
    function MarkMap(){
    $.get("function/jobmap.php", function(res){
          var d=JSON.parse(res);
      var count=0;
      for(i in d) {
      	count++;
      	if (count>20) return;
        var titlu=d[i][0];
        var location = new google.maps.LatLng(d[i][2],d[i][3]);
        var marker= new google.maps.Marker({
          position:location,
          map: map});
        markerArray.push(marker);
       
        var contentString = '<a href="post.php?entityid='+d[i][1]+'">'+d[i][0]+'</a>';  
        (function (marker, contentString) {
          google.maps.event.addListener(marker, 'click', function() {
          if (lastWindow!=null)
            lastWindow.close();
          var infowindow = new google.maps.InfoWindow({
            content: contentString
            });
          infowindow.open(map,marker);
          lastWindow=infowindow;
          (function(){infowindow.close()});
          });
        })(marker, contentString);
      }
    });
    
  }

    function deleteMarkers(){
    if(markerArray){
      for(i in markerArray){
        markerArray[i].setMap(null);
      }
    }

}